/*
 * @lc app=leetcode id=189 lang=cpp
 *
 * [189] Rotate Array
 */
class Solution {
public:
    void rotate(vector<int>& nums, int k) {

        int len = nums.size();
        if (len == 0 || (k = k%len)==0) {
            return ;
        }

        vector<int> extra(nums.end()-k, nums.end());
        for (int i=len-1; i>=k; i--) {
            nums[i] = nums[i-k];
        }
        for (int i=k-1; i>=0; i--) {
            nums[i] = extra[i];
        }
    }
};

